import Router from 'vue-router';
import Vue from 'vue';
Vue.use(Router)
const vueRouter = new Router({
  mode: 'history',
   base: '/tgcgzj',
  routes: [{
    path: '/',
    name: 'main',
    component: () => import('@/pages/Main'),
    children: [{
        path: '/',
        redirect:'/ldwq'
        // meta:{
        //   title:"智慧技能公共服务",
        //   notRightLinks:true
        // },
        // component: () => import('@/pages/children/index'),
      },
      {
        path: '/index',
        name: 'index',
        meta:{
          title:"",
          //notRightLinks:true,
        },
        component: () => import('@/pages/children/index'),
      },
      {
        path: '/sc',
        name: 'sc',
        meta:{
          title:"电子劳动合同",
          //notRightLinks:true,
        },
        component: () => import('@/pages/children/sc'),
      },
      {
        path: '/pdf',
        name: 'pdf',
        meta:{
          title:"电子劳动合同",
          //notRightLinks:true,
        },
        component: () => import('@/pages/children/pdf'),
      },
      {
        path: '/ldwq',
        name: 'ldwq',
        meta:{
          title:"电子劳动合同",
          //notRightLinks:true,
        },
        component: () => import('@/pages/children/ldwq'),
      },
      {
        path: '/wqldhtzs',
        name: 'wqldhtzs',
        meta:{
          title:"电子劳动合同指数",
          //notRightLinks:true,
        },
        component: () => import('@/pages/children/wqldhtzs'),
      },
      {
        path: '/ss',
        name: 'ss',
        meta:{
          title:"电子劳动合同指数",
          //notRightLinks:true,
        },
        component: () => import('@/pages/children/ss'),
      }
    ]
  }, ]
})
vueRouter.beforeEach((to, from, next) => {
  //路由执行前，this还未指向当前组件，不能用this取值或赋值
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
    vueRouter.app.$options.store.commit("setPageTitle", to.meta.title);
  }
  vueRouter.app.$options.store.commit("setShowRightLink", to.meta.notRightLinks);
  next();
})
export default vueRouter;
